home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / AIAT / Headers / Index / TFVector.h < prev    next >
Encoding:
Text File  |  1998-04-16  |  1.6 KB  |  66 lines  |  [TEXT/CWIE]

  1. // TFVector.h
  2. //    Copyright:    © 1994 - 1998 by Apple Computer, Inc., all rights reserved.
  3.  
  4. #pragma once
  5. #ifndef TFVector_h
  6. #define TFVector_h
  7.  
  8. #pragma import on
  9.  
  10. #if PRAGMA_STRUCT_ALIGN
  11.     #pragma options align=power
  12. #endif
  13.  
  14. #include "TermIndex.h"
  15.  
  16. #pragma IA_BEGIN_EXPORTS
  17.  
  18. // TFComponent: what TFVector's are made of.
  19. struct TFComponent {
  20.     TermID            termID;                // the TermID
  21.     TermFreq        freq;                // the frequency of that term
  22. private:
  23.     void*            operator new(size_t size);    // stack or array allocate only
  24. };
  25.  
  26. // order function so that arrays of TFComponent can be sorted by qsort
  27. extern "C" { int TFComponentOrder(const void* c1, const void* c2); }
  28.  
  29. // TFVector: available from a VectorIndex.
  30. class TFVector : public IAObject {
  31.     friend class    VectorIndex;
  32. public:
  33.                     TFVector(DocLength l);
  34.                     ~TFVector();
  35.  
  36.     bool Validate(bool verbose);
  37.     void    SetDocumentLength(DocLength len) {length = len;}
  38.     DocLength GetDocumentLength()  const {return length;}
  39.     
  40.     void    SetComponents(TFComponent* comps) {components = comps;}
  41.     TFComponent*    GetComponents() const {return components;}
  42. private:    
  43.     IABlockSize        ComponentsSize();
  44.     void            ComponentsWrite(IAOutputBlock* output);
  45.     void            ComponentsRead(IAInputBlock* input);
  46.  
  47.                     TFVector(TFVector&);            // don't define a copy constructor
  48.                     
  49.     DocLength        length;                    // the number of components in the vector
  50.     TFComponent*    components;                // an array of TFComponents, sorted by termID
  51.  
  52. };
  53.  
  54. // returns a new TFVector which is the sum of the argument vectors
  55. //TFVector*        SumTFVectors(TFVector** vectors, uint32 nVectors);
  56.  
  57. #pragma IA_END_EXPORTS
  58.  
  59. #if PRAGMA_STRUCT_ALIGN
  60.     #pragma options align=reset
  61. #endif
  62.  
  63. #pragma import reset
  64.  
  65. #endif
  66.